﻿<form method="post">
    <div class="querybar">
        <table cellpadding="0" cellspacing="1" border="0" width="100%">
            <tr>
                <td>
                    流程：<select class="myselect2" style="width:210px;" id="FlowID" name="FlowID"><option value=""></option>@Html.Raw(ViewData["flowOptions"])</select>
                    标题：<input type="text" class="mytext" id="Title" name="Title" style="width:200px;" />
                    接收时间：<input type="text" class="mycalendar" style="width:90px;" id="Date1" name="Date1" /> 至 <input type="text" style="width:90px;" class="mycalendar" id="Date2" name="Date2" />
                    <input type="button" name="Search" onclick="query(null, 1);" value="查询" class="mybutton" />
                </td>
            </tr>
        </table>
    </div>
    <table id="listtable"></table>
    <div class="buttondiv"></div>
</form>
<script type="text/javascript">
    var currentPage, currentNumber;
    $(function ()
    {
        $("#listtable").jqGrid({
            url: "QueryCompleted?@Html.Raw(ViewData["query"])",
            mtype: 'POST',
            datatype: "json",
            colNames: ['标题', '流程', '步骤', '发送人', '接收时间', '完成时间', '备注', ''],
            colModel: [
                { name: 'Title', index: 'Title' },
                { name: 'FlowName', index: 'FlowID', align: "left" },
                { name: 'StepName', index: 'StepID', align: "left", width: 80 },
                { name: 'SenderName', index: 'SenderName', align: "left", width: 50 },
                { name: 'ReceiveTime', index: 'ReceiveTime', align: "left", width: 110 },
                { name: 'CompletedTime', index: 'CompletedTime1', align: "left", width: 110 },
                { name: 'Note', index: 'Note', sortable: false, align: "left", width: 60 },
                { name: 'Opation', index: '', sortable: false, title: false, align: "left", width: 80 }
            ],
            sortname: "CompletedTime1",
            sortorder: "desc",
            height: '100%',
            width: $(window).width(),
            loadComplete: function ()
            {
                var gridObj = $("#listtable");
                var records = gridObj.getGridParam("userData");
                currentPage = records.pagesize;
                currentNumber = records.pagenumber;
                $(".buttondiv").html(RoadUI.Core.getPager1(records.total, records.pagesize, records.pagenumber, "query"));
            }
        });
    });
    $(window).resize(function () {
        $("#listtable").setGridWidth($(window).width());
    });
    function query(size, number)
    {
        var data = {
            title: $("#Title").val(), flowid: $("#FlowID").val(),
            sender: $("#SenderID").val(), date1: $("#Date1").val(), date2: $("#Date2").val(),
            pagesize: size, pagenumber: number
        };
        $("#listtable").setGridParam({ postData: data }).trigger("reloadGrid");
    }
    function openTask(url, title, id, openModel, width, height)
    {
        top.openApp(url, openModel, title, id, width, height, false);
    }
    function detail(flowid, groupid)
    {
        new RoadUI.Window().open({
            url: 'Detail?flowid=' + flowid + "&groupid=" + groupid + '&@Html.Raw(ViewData["query"])',
            width: 1024, height: 550, title: "查看流程处理过程", opener: window
        });
    }
    function withdraw(taskID)
    {
        if (confirm("您真的要收回该任务吗?"))
        {
            $.ajax({
                url: "Withdraw?taskid=" + taskID + '&@Html.Raw(ViewData["query"])',
                cache: false,
                async: false,
                success: function (txt)
                {
                    alert(txt);
                    query(currentPage, currentNumber);
                }
            });
        }
    }
    function hasten(taskID)
    {
        new RoadUI.Window().open({
            url: 'Hasten?taskid=' + taskID + '&@Html.Raw(ViewData["query"])',
            width: 600, height: 300, title: "任务催办", opener: window, openerid: "${tabId}"
        });
    }
</script>
